const path = require('path');
module.exports = {
    stories: [
        '../src/**/*.stories.mdx',
        '../src/**/*.stories.@(js|jsx|ts|tsx)',
    ],
    addons: [
        '@storybook/addon-links',
        '@storybook/addon-essentials',
        {
            name: '@storybook/preset-create-react-app',
            options: {
                craOverrides: {
                    fileLoaderExcludes: ['less'], //阻止 preset-create-react-app 处理less 文件
                },
            },
        },
    ],
    webpackFinal: async (config) => {
        config.module.rules.push({
            test: /\.less$/,//开启less 的 处理
            loaders: [
                'style-loader',
                'css-loader',
                {
                    loader: 'less-loader',
                    options: {
                        lessOptions: {
                            javascriptEnabled: true,
                        },
                    },
                },
            ],
            include: [
                path.resolve(__dirname, '../src'),
                /[\\/]node_modules[\\/].*antd/,
            ],
        });

        config.resolve.extensions.push('.ts', '.tsx');

        return config;
    },
};
